﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:es="clr-namespace:Microsoft.Expression.Shapes;assembly=Microsoft.Expression.Drawing" 
    xmlns:em="clr-namespace:Microsoft.Expression.Media;assembly=Microsoft.Expression.Drawing"
    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
    xmlns:UX="clr-namespace:Omnia.UX;assembly=Omnia.UX"
    xmlns:viewmodel="clr-namespace:Omnia.ViewModels;assembly=Omnia.ViewModels"
    x:Class="Omnia.Wallet.Views.CasesView"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="False" d:DesignHeight="800" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:CaseViewModel/>
        </Grid.DataContext>
    	<Grid.Background>
    		<ImageBrush Stretch="{Binding GlobalSettings.BackgroundImageStretch}" ImageSource="{Binding BackgroundImageSource, Mode=OneWay}"/>
    	</Grid.Background>
        <Grid.RowDefinitions>
        	<RowDefinition Height="Auto"/>
        	<RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="12,17,0,12">
            <TextBlock Text="{StaticResource IDS_PAGE_TITLE}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_PAGE_HEADER_CASE_ALL}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
            	<RowDefinition/>
            	<RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <ListBox ItemsSource="{Binding ShowCasesCollection}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid Margin="12,0">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates"/>
                                            <VisualStateGroup x:Name="FocusStates"/>
                                            <VisualStateGroup x:Name="SelectionStates" 
                                                              ec:ExtendedVisualStateManager.UseFluidLayout="True">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0:0:1" To="Unselected">
                                                        <VisualTransition.GeneratedEasingFunction>
                                                            <BackEase EasingMode="EaseIn" Amplitude="0"/>
                                                        </VisualTransition.GeneratedEasingFunction>
                                                    </VisualTransition>
                                                    <VisualTransition GeneratedDuration="0">
                                                        <VisualTransition.GeneratedEasingFunction>
                                                            <CubicEase EasingMode="EaseIn"/>
                                                        </VisualTransition.GeneratedEasingFunction>
                                                    </VisualTransition>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Unselected">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0:0:1" 
                                                                         To="0"
                                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" 
                                                                         Storyboard.TargetName="grid"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Selected">
                                                    <Storyboard RepeatBehavior="Forever">
                                                        <DoubleAnimation Duration="0:0:1"
                                                                         To="360" 
                                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" 
                                                                         Storyboard.TargetName="grid"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                                                       Storyboard.TargetName="detailBtn">
                                                        	<DiscreteObjectKeyFrame KeyTime="0">
                                                        		<DiscreteObjectKeyFrame.Value>
                                                        			<Visibility>Visible</Visibility>
                                                        		</DiscreteObjectKeyFrame.Value>
                                                        	</DiscreteObjectKeyFrame>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="SelectedUnfocused"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <VisualStateManager.CustomVisualStateManager>
                                            <ec:ExtendedVisualStateManager/>
                                        </VisualStateManager.CustomVisualStateManager>
                                        <Grid Width="65" HorizontalAlignment="Left">
                                            <Rectangle Width="1" Fill="{StaticResource PhoneAccentBrush}"/>

                                            <TextBlock Style="{StaticResource PhoneTextSmallStyle}" 
                                                       Text="{Binding StartDate.Year}" 
                                                       HorizontalAlignment="Center" 
                                                       Margin="0,89,0,0" 
                                                       VerticalAlignment="Top"/>
                                        </Grid>

                                        <Grid Margin="0,12" VerticalAlignment="Top">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition/>
                                                <ColumnDefinition Width="24"/>
                                            </Grid.ColumnDefinitions>
                                            <Ellipse Width="65" Height="65" 
                                                     Fill="{StaticResource PhoneAccentBrush}" VerticalAlignment="Top"/>
                                            <StackPanel VerticalAlignment="Center" 
                                                        HorizontalAlignment="Center">
                                                <TextBlock Style="{StaticResource PhoneTextNormalStyle}" 
                                                           Text="{Binding StartDate.Month}" 
                                                           HorizontalAlignment="Center"/>
                                                <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                           Text="{Binding StartDate.Day, Mode=OneWay}" 
                                                           VerticalAlignment="Center" 
                                                           HorizontalAlignment="Center"/>
                                            </StackPanel>
                                            <es:RegularPolygon Fill="{StaticResource PhoneSubtleBrush}" 
                                                               HorizontalAlignment="Right"
                                                               Height="16" InnerRadius="1" 
                                                               PointCount="3" Stretch="Fill"
                                                               UseLayoutRounding="False"
                                                               VerticalAlignment="Center" 
                                                               Width="24" StrokeThickness="0" 
                                                               Grid.Column="1" 
                                                               RenderTransformOrigin="0.5,0.5" Margin="0,0,-4,0">
                                                <es:RegularPolygon.RenderTransform>
                                                    <CompositeTransform Rotation="-90"/>
                                                </es:RegularPolygon.RenderTransform>
                                            </es:RegularPolygon>
                                            <Grid x:Name="grid" RenderTransformOrigin="0.5,0.5">
                                                <Grid.RenderTransform>
                                                    <CompositeTransform/>
                                                </Grid.RenderTransform>
                                                <Ellipse Fill="#FFF4F4F5" 
                                                         HorizontalAlignment="Right" 
                                                         Height="5" 
                                                         VerticalAlignment="Center" 
                                                         Width="5"/>
                                            </Grid>

                                        </Grid>
                                        
                                        <Border  Grid.Column="1" CornerRadius="5" 
                                                 Background="{StaticResource PhoneSubtleBrush}" 
                                                 Margin="0,24,0,12">
                                            <StackPanel>
                                                <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                                           Text="{Binding Title}" 
                                                           Foreground="{StaticResource PhoneChromeBrush}"/>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition Width="1"/>
                                                        <ColumnDefinition/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid  Background="{StaticResource PhoneSubtleBrush}">
                                                        <StackPanel HorizontalAlignment="Center">
                                                            <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                                       Foreground="{StaticResource PhoneBackgroundBrush}"
                                                                       Text="{Binding SumOfIncome}" 
                                                                       HorizontalAlignment="Center"/>
                                                            <TextBlock Style="{StaticResource PhoneTextSmallStyle}" 
                                                                       Text="{StaticResource IDS_LABEL_CASE_INCOME}" HorizontalAlignment="Center" 
                                                                       Foreground="{StaticResource PhoneChromeBrush}"/>
                                                        </StackPanel>
                                                    </Grid>

                                                    <Grid  Background="{StaticResource PhoneSubtleBrush}" Grid.Column="2">
                                                        <StackPanel HorizontalAlignment="Center">
                                                            <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                                       Foreground="{StaticResource PhoneBackgroundBrush}" 
                                                                       Text="{Binding SumOfExpense}" 
                                                                       HorizontalAlignment="Center"/>
                                                            <TextBlock Style="{StaticResource PhoneTextSmallStyle}" 
                                                                       Text="{StaticResource IDS_LABEL_CASE_EXPENSE}" 
                                                                       HorizontalAlignment="Center" 
                                                                       Foreground="{StaticResource PhoneChromeBrush}"/>
                                                        </StackPanel>
                                                    </Grid>
                                                </Grid>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition Width="auto"/>
                                                    </Grid.ColumnDefinitions>
                                                    <StackPanel>
                                                        <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                                   Text="{Binding TransactionCount}" 
                                                                   Foreground="{StaticResource PhoneChromeBrush}"/>
                                                        <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                                   Text="{Binding Place}"
                                                                   Foreground="{StaticResource PhoneChromeBrush}"/>
                                                    </StackPanel>
                                                    
                                                    <UX:UXPathButtonWithUriAndParameter x:Name="detailBtn"
                                                                                        Grid.Column="1" 
                                                                                        VerticalAlignment="Bottom" 
                                                                                        Width="30" Height="30" Margin="0,0,12,12"
                                                                                        Visibility="Collapsed" 
                                                                                        Uri="/Views/CaseDetailsView.xaml" 
                                                                                        PamaterName="Guid" 
                                                                                        PamaterValue="{Binding Guid}">
                                                        <UX:UXPathButtonWithUriAndParameter.Style>
                                                            <Style TargetType="UX:UXPathButtonWithUriAndParameter">
                                                                <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
                                                                <Setter Property="Template">
                                                                    <Setter.Value>
                                                                        <ControlTemplate TargetType="UX:UXPathButtonWithUriAndParameter">
                                                                            <Grid>
                                                                                <Grid Background="White" Opacity="0"/>
                                                                                <Ellipse Stroke="{TemplateBinding Foreground}" StrokeThickness="2"/>
                                                                                <Path VerticalAlignment="Center" 
                                                                                      Data="{Binding Source={StaticResource PATH_ICON_DETAIL}}" 
                                                                                      Stretch="Uniform"
                                                                                      Width="16" Height="16" Margin="6" 
                                                                                      RenderTransformOrigin="0.5,0.5" 
                                                                                      x:Name="el" 
                                                                                      Fill="{TemplateBinding Foreground}">
                                                                                    <Path.RenderTransform>
                                                                                        <TransformGroup>
                                                                                            <RotateTransform Angle="0" />
                                                                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                                        </TransformGroup>
                                                                                    </Path.RenderTransform>
                                                                                </Path>
                                                                            </Grid>
                                                                        </ControlTemplate>
                                                                    </Setter.Value>
                                                                </Setter>
                                                            </Style>
                                                        </UX:UXPathButtonWithUriAndParameter.Style>
                                                    </UX:UXPathButtonWithUriAndParameter>
                                                </Grid>
                                            </StackPanel>
                                        </Border>

                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

            <CheckBox Grid.Row="1" HorizontalAlignment="Left"
                      VerticalAlignment="Center" 
                      Content="{StaticResource IDS_LABEL_CASE_ONLYSHOWCURRENTYEAR}" 
                      IsChecked="{Binding FliterCurrentYear, Mode=TwoWay}"/>
            <UX:UXPathButton IconPath="{StaticResource PATH_ICON_CLOSE}" 
                             Angle="45" Margin="12" Uri="/Views/CaseAddView.xaml" 
                             Padding="13"
                             Grid.Row="1" HorizontalAlignment="Right"/>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>